package com.ccjt.efcfs.dto;

import com.ccjt.efcfs.util.DecimalUtils;

import static com.ccjt.efcfs.constant.CalculateConstant.Decimal.BD_TEN;
import static com.ccjt.efcfs.constant.CalculateConstant.Decimal.BD_ZERO;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 还款分期计划(计算用)
 */
public class RepayPlanCal {

    private String batchNo; // 批次号
    private BigDecimal planPeriods; // 计划期数
    private BigDecimal curPeriod; // 当前期数
    private Date beginDate; // 本期开始日期（初始为贷款放款日期）
    private Date repayDate; // 本期(实际)还款日期
    private Date endDate; // 本期(计划)还款日期
    private BigDecimal curPeriodCycleDays; // 本期计划周期天数，金融算法为30天/月
    private BigDecimal curPeriodNatureDays; // 本期自然天数
    private BigDecimal yearRate; // 年利率
    private BigDecimal monthRate; // (月)利率
    private BigDecimal financeDayRate; // (金融日)利率 : 360
    private BigDecimal natureDayRate; // (自然日)利率 : 365/366
    private BigDecimal actualDayRate; // (实际)利率
    private BigDecimal monthBeginResidualPrincipal; // (月)本期开始剩余本金
    private BigDecimal monthBeginIncreasedInterest; // (月)本期开始累计归还利息
    //    private BigDecimal monthEndResidualPrincipal; // (月)本期剩余本金
//    private BigDecimal monthEndIncreasedInterest; // (月)本期累计归还利息
    private BigDecimal monthPerRepayPrincipal; // (月)本期归还本金
    private BigDecimal monthPerRepayInterest; // (月)本期归还利息
    private BigDecimal monthPerRepayTotal; // (月)本期归还本息合计
    private BigDecimal financeBeginResidualPrincipal; // (金融日)本期开始剩余本金
    private BigDecimal financeBeginIncreasedInterest; // (金融日)本期开始累计归还利息
    //    private BigDecimal financeEndResidualPrincipal; // (金融日)本期剩余本金
//    private BigDecimal financeEndIncreasedInterest; // (金融日)本期累计归还利息
    private BigDecimal financePerRepayPrincipal; // (金融日)本期归还本金
    private BigDecimal financePerRepayInterest; // (金融日)本期归还利息
    private BigDecimal financePerRepayTotal; // (金融日)本期归还本息合计
    private BigDecimal natureBeginResidualPrincipal; // (自然日)本期开始剩余本金
    private BigDecimal natureBeginIncreasedInterest; // (自然日)本期开始累计归还利息
    //    private BigDecimal natureEndResidualPrincipal; // (自然日)本期剩余本金
//    private BigDecimal natureEndIncreasedInterest; // (自然日)本期累计归还利息
    private BigDecimal naturePerRepayPrincipal; // (自然日)本期归还本金
    private BigDecimal naturePerRepayInterest; // (自然日)本期归还利息
    private BigDecimal naturePerRepayTotal; // (自然日)本期归还本息合计
    private BigDecimal actualBeginResidualPrincipal; // (实际)本期开始剩余本金
    private BigDecimal actualBeginIncreasedInterest; // (实际)本期开始累计归还利息
    //    private BigDecimal actualEndResidualPrincipal; // (实际)本期剩余本金
//    private BigDecimal actualEndIncreasedInterest; // (实际)本期累计归还利息
    private BigDecimal actualPerRepayPrincipal; // (实际)本期归还本金
    private BigDecimal actualPerRepayInterest; // (实际)本期归还利息
    private BigDecimal actualPerRepayTotal; // (实际)本期归还本息合计


    /**
     * 当前期数序号=当前期数x10
     */
    public BigDecimal getCurPeriodOrder() {
        return curPeriod.multiply(BD_TEN);
    }

    /**
     * (月)本期剩余本金 = (月)本期开始剩余本金 - (月)本期归还本金
     */
    public BigDecimal getMonthEndResidualPrincipal() {
        return DecimalUtils.sub(monthBeginResidualPrincipal, monthPerRepayPrincipal);
    }

    /**
     * (月)本期累计归还利息 = (月)本期开始累计归还利息 + (月)本期归还利息
     */
    public BigDecimal getMonthEndIncreasedInterest() {
        return DecimalUtils.add(monthBeginIncreasedInterest, monthPerRepayInterest);
    }


    /**
     * (金融日)本期剩余本金 = (金融日)本期开始剩余本金 - (金融日)本期归还本金
     */
    public BigDecimal getFinanceEndResidualPrincipal() {
        return DecimalUtils.sub(financeBeginResidualPrincipal, financePerRepayPrincipal);
    }

    /**
     * (金融日)本期累计归还利息 = (金融日)本期开始累计归还利息 + (金融日)本期归还利息
     */
    public BigDecimal getFinanceEndIncreasedInterest() {
        return DecimalUtils.add(financeBeginIncreasedInterest, financePerRepayInterest);
    }


    /**
     * (自然日)本期剩余本金 = (自然日)本期开始剩余本金 - (自然日)本期归还本金
     */
    public BigDecimal getNatureEndResidualPrincipal() {
        return DecimalUtils.sub(natureBeginResidualPrincipal, naturePerRepayPrincipal);
    }

    /**
     * (自然日)本期累计归还利息 = (自然日)本期开始累计归还利息 + (自然日)本期归还利息
     */
    public BigDecimal getNatureEndIncreasedInterest() {
        return DecimalUtils.add(natureBeginIncreasedInterest, naturePerRepayInterest);
    }

    /**
     * (实际)本期剩余本金 = (实际)本期开始剩余本金 - (实际)本期归还本金
     */
    public BigDecimal getActualEndResidualPrincipal() {
        return DecimalUtils.sub(actualBeginResidualPrincipal, actualPerRepayPrincipal);
    }

    /**
     * (实际)本期累计归还利息 = (实际)本期开始累计归还利息 + (实际)本期归还利息
     */
    public BigDecimal getActualEndIncreasedInterest() {
        return DecimalUtils.add(actualBeginIncreasedInterest, actualPerRepayInterest);
    }


    /*********************************************************/
    public String getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }

    public BigDecimal getPlanPeriods() {
        return planPeriods;
    }

    public void setPlanPeriods(BigDecimal planPeriods) {
        this.planPeriods = planPeriods;
    }

    public BigDecimal getCurPeriod() {
        return curPeriod;
    }

    public void setCurPeriod(BigDecimal curPeriod) {
        this.curPeriod = curPeriod;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getRepayDate() {
        return repayDate;
    }

    public void setRepayDate(Date repayDate) {
        this.repayDate = repayDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public BigDecimal getCurPeriodCycleDays() {
        return curPeriodCycleDays;
    }

    public void setCurPeriodCycleDays(BigDecimal curPeriodCycleDays) {
        this.curPeriodCycleDays = curPeriodCycleDays;
    }

    public BigDecimal getCurPeriodNatureDays() {
        return curPeriodNatureDays;
    }

    public void setCurPeriodNatureDays(BigDecimal curPeriodNatureDays) {
        this.curPeriodNatureDays = curPeriodNatureDays;
    }

    public BigDecimal getYearRate() {
        return yearRate;
    }

    public void setYearRate(BigDecimal yearRate) {
        this.yearRate = yearRate;
    }

    public BigDecimal getMonthRate() {
        return monthRate;
    }

    public void setMonthRate(BigDecimal monthRate) {
        this.monthRate = monthRate;
    }

    public BigDecimal getFinanceDayRate() {
        return financeDayRate;
    }

    public void setFinanceDayRate(BigDecimal financeDayRate) {
        this.financeDayRate = financeDayRate;
    }

    public BigDecimal getNatureDayRate() {
        return natureDayRate;
    }

    public void setNatureDayRate(BigDecimal natureDayRate) {
        this.natureDayRate = natureDayRate;
    }

    public BigDecimal getActualDayRate() {
        return actualDayRate;
    }

    public void setActualDayRate(BigDecimal actualDayRate) {
        this.actualDayRate = actualDayRate;
    }

    public BigDecimal getMonthBeginResidualPrincipal() {
        return monthBeginResidualPrincipal;
    }

    public void setMonthBeginResidualPrincipal(BigDecimal monthBeginResidualPrincipal) {
        this.monthBeginResidualPrincipal = monthBeginResidualPrincipal;
    }

    public BigDecimal getMonthBeginIncreasedInterest() {
        return monthBeginIncreasedInterest;
    }

    public void setMonthBeginIncreasedInterest(BigDecimal monthBeginIncreasedInterest) {
        this.monthBeginIncreasedInterest = monthBeginIncreasedInterest;
    }

    public BigDecimal getMonthPerRepayPrincipal() {
        return monthPerRepayPrincipal;
    }

    public void setMonthPerRepayPrincipal(BigDecimal monthPerRepayPrincipal) {
        this.monthPerRepayPrincipal = monthPerRepayPrincipal;
    }

    public BigDecimal getMonthPerRepayInterest() {
        return monthPerRepayInterest;
    }

    public void setMonthPerRepayInterest(BigDecimal monthPerRepayInterest) {
        this.monthPerRepayInterest = monthPerRepayInterest;
    }

    public BigDecimal getMonthPerRepayTotal() {
        return monthPerRepayTotal;
    }

    public void setMonthPerRepayTotal(BigDecimal monthPerRepayTotal) {
        this.monthPerRepayTotal = monthPerRepayTotal;
    }

    public BigDecimal getFinanceBeginResidualPrincipal() {
        return financeBeginResidualPrincipal;
    }

    public void setFinanceBeginResidualPrincipal(BigDecimal financeBeginResidualPrincipal) {
        this.financeBeginResidualPrincipal = financeBeginResidualPrincipal;
    }

    public BigDecimal getFinanceBeginIncreasedInterest() {
        return financeBeginIncreasedInterest;
    }

    public void setFinanceBeginIncreasedInterest(BigDecimal financeBeginIncreasedInterest) {
        this.financeBeginIncreasedInterest = financeBeginIncreasedInterest;
    }

    public BigDecimal getFinancePerRepayPrincipal() {
        return financePerRepayPrincipal;
    }

    public void setFinancePerRepayPrincipal(BigDecimal financePerRepayPrincipal) {
        this.financePerRepayPrincipal = financePerRepayPrincipal;
    }

    public BigDecimal getFinancePerRepayInterest() {
        return financePerRepayInterest;
    }

    public void setFinancePerRepayInterest(BigDecimal financePerRepayInterest) {
        this.financePerRepayInterest = financePerRepayInterest;
    }

    public BigDecimal getFinancePerRepayTotal() {
        return financePerRepayTotal;
    }

    public void setFinancePerRepayTotal(BigDecimal financePerRepayTotal) {
        this.financePerRepayTotal = financePerRepayTotal;
    }

    public BigDecimal getNatureBeginResidualPrincipal() {
        return natureBeginResidualPrincipal;
    }

    public void setNatureBeginResidualPrincipal(BigDecimal natureBeginResidualPrincipal) {
        this.natureBeginResidualPrincipal = natureBeginResidualPrincipal;
    }

    public BigDecimal getNatureBeginIncreasedInterest() {
        return natureBeginIncreasedInterest;
    }

    public void setNatureBeginIncreasedInterest(BigDecimal natureBeginIncreasedInterest) {
        this.natureBeginIncreasedInterest = natureBeginIncreasedInterest;
    }

    public BigDecimal getNaturePerRepayPrincipal() {
        return naturePerRepayPrincipal;
    }

    public void setNaturePerRepayPrincipal(BigDecimal naturePerRepayPrincipal) {
        this.naturePerRepayPrincipal = naturePerRepayPrincipal;
    }

    public BigDecimal getNaturePerRepayInterest() {
        return naturePerRepayInterest;
    }

    public void setNaturePerRepayInterest(BigDecimal naturePerRepayInterest) {
        this.naturePerRepayInterest = naturePerRepayInterest;
    }

    public BigDecimal getNaturePerRepayTotal() {
        return naturePerRepayTotal;
    }

    public void setNaturePerRepayTotal(BigDecimal naturePerRepayTotal) {
        this.naturePerRepayTotal = naturePerRepayTotal;
    }

    public BigDecimal getActualBeginResidualPrincipal() {
        return actualBeginResidualPrincipal;
    }

    public void setActualBeginResidualPrincipal(BigDecimal actualBeginResidualPrincipal) {
        this.actualBeginResidualPrincipal = actualBeginResidualPrincipal;
    }

    public BigDecimal getActualBeginIncreasedInterest() {
        return actualBeginIncreasedInterest;
    }

    public void setActualBeginIncreasedInterest(BigDecimal actualBeginIncreasedInterest) {
        this.actualBeginIncreasedInterest = actualBeginIncreasedInterest;
    }

    public BigDecimal getActualPerRepayPrincipal() {
        return actualPerRepayPrincipal;
    }

    public void setActualPerRepayPrincipal(BigDecimal actualPerRepayPrincipal) {
        this.actualPerRepayPrincipal = actualPerRepayPrincipal;
    }

    public BigDecimal getActualPerRepayInterest() {
        return actualPerRepayInterest;
    }

    public void setActualPerRepayInterest(BigDecimal actualPerRepayInterest) {
        this.actualPerRepayInterest = actualPerRepayInterest;
    }

    public BigDecimal getActualPerRepayTotal() {
        return actualPerRepayTotal;
    }

    public void setActualPerRepayTotal(BigDecimal actualPerRepayTotal) {
        this.actualPerRepayTotal = actualPerRepayTotal;
    }
}
